Copyright: Copyright © 1996 TegoSoft Inc. (Version 101696.01)
Citation: Copyright © 1996 TegoSoft Inc.


What is 3-D Virtual Reality?

Page 1 of 4

What is 3-D Virtual Reality?

What is 3-D Virtual Reality?

One of the most fascinating programs that you can write for Windows is the so called 3-D Virtual Reality program.

The name of the program that you downloaded from the TegoSoft Web site is World3D.EXE, and this program is an example of a 3-D Virtual Reality program. Before you start executing the World3D.EXE program, let's quickly review some introduction material that explains about this fascinating technology.

A 3-D Virtual Reality program is a program that lets the user "travel" inside a 3-D (three dimensional) picture. The 3-D Virtual Reality program displays 3-D pictures, and the user uses the mouse (or the keyboard) to "travel" inside the 3-D picture. As the user "moves" inside the 3-D picture, the 3-D Virtual Reality program displays different pictures that correspond to the new location of the user inside the 3-D picture. For example, suppose that the 3-D picture is a picture of a floor in a building. The 3-D Virtual Reality program displays a picture of one of the rooms in the floor. The user can exit the room, wonder about the halls of the floor, enter other rooms, and so on. As the user moves on the floor, the 3-D Virtual Reality program displays the 3-D pictures that the user would have seen if he/she was traveling inside the real floor of the building.

So to summarize, although the user of the 3-D Virtual Reality program does his/her "traveling" while sitting on a chair and holding a mouse, the 3-D virtual Reality program gives the user the illusion that he/she is moving in a real 3-dimensional environment.

Interacting with Animated Objects

When implementing a 3-D Virtual Reality program, typically you will also let the user interact with other animated objects that your program places inside the 3-D picture. For example, your 3-D Virtual Reality program will display pictures of people, robots, creatures from out of space, and other good and evil characters. Your user will be able to interact with these objects (the user can collide with the objects, shoot the objects, the objects can shoot the user, and so on).

In short, the 3-D Virtual Reality program that you can implement with Visual Basic lets you build your own world with everything that you wish in it!


Make it fast with WinG

Page 2 of 4

Make it Fast With WinG

Make it Fast With WinG

As stated in the previous page, in 3-D Virtual Reality programs the user can "travel" inside 3-D pictures. As the user moves inside the 3-D picture, the program should display new pictures continuously. For each movement of the user (even the slightest move), a new 3-D picture is displayed. This means that the PC has to work very hard. In real time, the PC has to display different 3-D pictures that correspond to the user's movements.

The problem with Windows (Windows 3.1x, Windows 95, Windows NT) is that these operating systems are not fast enough to perform such graphical operations. To understand why Windows is very slow to perform graphical operations, let's first look how the good old DOS operating system performs graphical operations.

In DOS, the program directly touches the memory of the video card of the monitor. The memory of the video card corresponds to pixels on the screen. So as soon as the DOS program changes the value of a memory inside the video card, the pixel corresponding to the memory changes accordingly. To summarize, the DOS program can change the pixels of the monitor by directly accessing the memory that corresponds to these pixels. This means that DOS programs can perform very fast graphical operations. In fact, as fast as one can hope.

But the problem with DOS is that the program that you write with DOS are device dependent. That is, you have to write different DOS programs for different video cards. If you are using a video card of one particular manufacturer, then the DOS program that you write has to access the video card in a certain way dictated by the manufacturer of the video card. If your user uses a different type of video card, the DOS program must be changed accordingly, because the manufacturer of the other video card designed the video card in a different way.

In Windows however,  the user can use any video card. As long as Windows accepted the equipment at the time the equipment was installed, the equipment should work fine with every Windows program. The Windows programs that you write are the same no matter what device your user uses (hence the term device independent).

The device independence feature of Windows means that during the execution of the Windows program that performs graphical operation, Windows executes various layers of software (called driver programs) that "touch" the video card in the proper way. The bottom line is as follows:

When your Windows program issues a command to change a pixel on the screen, a lot is happening between the time the command is issued and the time the pixel is changed. Eventually, the command to change a pixel on the screen is executed, but it takes a lot of time for the command to be executed. Of course, if your Windows program performs simple graphical operations, the delay in performing the graphical operation is not noticeable. So when using a word processor program for example, the delay that occurs during the execution of the word processor program is not noticeable.

But when performing very fast graphics operations (such as the graphics operations that are needed when implementing 3-D Virtual Reality programs), Windows is useless. That is, the Windows program will not be able to keep up with the requirement of the user to move fast inside the 3-D picture. If you implement a 3-D Virtual Reality program with Windows technology, your user will notice that as he/she is moving the mouse, the time it takes to react to the movement is too long. Furthermore, there will be a lot of flickering on the screen. In short, Windows is not suitable for this type of operation.

WinG to the Rescue...

Microsoft realized the graphics limitation of Windows, and therefore developed new technology called WinG, that enhance the graphics capabilities of Windows.

 WinG technology. WinG technology is available for 16-bit Windows (Windows version 3.1x), and WinG is also available for 32-bit Windows (Windows 95 and Windows NT).

.


Installing WinG and the required runtime modules

Page 3 of 4

Installing WinG and the Required Runtime Modules

Installing WinG and the Required Runtime Modules

Before continuing with the subject of executing the World3D.EXE program, let's install WinG, and the required runtime modules.

 NOTE

Nowadays, modern modular programming languages such as Visual Basic 4.0, Visual C++ 4.0 and many other programming languages utilize OCX technology.

When using OCX technology, your C:\Windows\System directory must contain several DLL files (called runtime modules).

Most probably, you already have some or all the required DLL files in your system. However, before executing the World3D.EXE program, you must make sure that you have all the required runtime modules as explained below.

 NOTE

If you are using a program such as the Explorer program of Windows 95 to copy the required DLL files, then you must make sure to set the Explorer program to view all files. That is, make sure that the Explorer is capable to view DLL files as follows:

 Select Options from the View menu of the Explorer.

Explorer responds by displaying the Options dialog box (see Figure 1)

 Click the View tab of the Options dialog box, and then make sure that the Show all files radio button is selected (see Figure 1)

Now that the Explorer is set to view all files, you can view DLL files with the Explorer.

Figure 1. Select Options from the View menu of the Explorer program to display the Options dialog box. Inside the View page of the Options dialog box, make sure that the Show all files radio button is selected.

Required DLL Files when using OCX Technology

The World3D.EXE program utilizes OCX technology. Hence, you must verify that the following files reside inside your C:\Windows\System directory (or inside your C:\Windows\System32 directory if you are using Windows NT):

 Mfc40.DLL

 Msvcrt40.DLL

 Olepro32.DLL

If you are missing any of the preceding files, then download the missing file(s) as follows:

 Log into the TegoSoft Web site at:

http://www.tegosoft.com

 Scroll down the home page of the TegoSoft Web site until you see the Index.  One of the items in the Index is Download Runtime DLL files. Click this item from the Index to view the Download Required Runtime Modules page.

 Inside the Download Required Runtime Modules page click the MFC.EXE hyper linked text to download the MFC.EXE file. Save the MFC.EXE file inside an empty temporary directory on your hard drive.

 The MFC.EXE file that you downloaded is a self-extract file. Use the Explorer or the File Manager program to double click the MFC.EXE file inside the directory where you save this file.

The MFC.EXE file responds by extracting files. The extracted files are the DLL files that are needed when utilizing OCX technology.

 Copy the DLL files that were extracted from the MFC.EXE file into your C:\Windows\System directory (or into your C:\Windows\System32 directory if you are using Windows NT).

 NOTE

 In the preceding step you are instructed to copy some DLL files to your C:\Windows\System directory. Most probably, some of these DLL files are already in your C:\Windows\System directory. While copying the files you'll get a message that tells you this.

 If you are using the Explorer program of Windows 95 to copy the DLL files, then make sure that the Explorer program is set to Show all files as explained previously in this page of this lesson (see Figure 1)  This way, your Explorer program will be able to display the DLL files, and you'll be able to use the Explorer program to copy the DLL files.

 If you are receiving a sharing violation error message while copying the DLL files and the copy operation is aborted, it is because currently, Visual Basic (or another program such as Visual C++) is running and is using the DLL file that you are trying to copy. In this case, exit Visual Basic (or the other program the uses the DLL), and then start the copy operation again.

Copying the Required OCX files

The World3D.EXE program utilizes two OCX controls:

 TegFlr32.OCX

 TegoMM32.OCX

You can see the preceding OCX files inside the C:\FromTego\3DVR\OCX32 directory. (That is, you already downloaded the 3DVR.EXE self-extract file from the TegoSoft Web site,  you saved the 3DVR.EXE file inside the C:\FromTego directory, and you expanded the 3DVR.EXE file. As a result, you created the C:\FromTego\3DVR\OCX32 directory).

 If you are using Windows 95, then copy the TegFlr32.OCX file from the C:\FromTego\3DVR\OCX32 directory to your C:\Windows\System directory.

If you are using Windows NT, then copy the file TegFlr32.OCX from the C:\FromTego\OCX32 directory to your C:\Windows\System32 directory.

Because the World3D.EXE program that you are going to execute plays music (MIDI sound file) and speech (WAV sound file), you need to copy the multimedia OCX control as follows:

 If you are using Windows 95, then copy the TegoMM32.OCX file from the C:\FromTego\3DVR\OCX32 directory to your C:\Windows\System directory.

If you are using Windows NT, then copy the file TegoMM32.OCX from the C:\FromTego\3DVR\OCX32 directory to your C:\Windows\System32 directory.

The Required DLL File When using a Visual Basic Program

You can design a program such as the World3D.EXE program with any programming language that is capable of utilizing OCX technology (e.g., Visual Basic 4.0, Visual C++ 4.0, and many others). The World3D.EXE program was written using Visual Basic 4.0.

When executing a program that was written with Visual Basic 4.0, you must have the file VB40032.DLL inside your system.

If you installed Visual Basic 4.0 into your PC, one of the files that were copied to your PC is the VB40032.DLL. If you are using Windows 95, the VB40032.DLL file was copied into your C:\Windows\System directory. If you are using Windows NT, the VB40032.DLL file was copied into your C:\Windows\System32 directory.

If you do not have Visual Basic installed on your PC and you would like the see the World3D.EXE program in action, then you must copy the VB40032.DLL file into your system as follows:

 Use your Explorer program or the File Manager program to check if your C:\Windows\System directory (or C:\Windows\System32 directory if you are using Windows NT) has the VB40032.DLL file in it. If you are using the Explorer program, don't forget to set the View all files options as shown in Figure 1

If you do not have the VB40032.DLL file, then copy this file to your system as follows:

 Log into the TegoSoft Web site at:

http://www.tegosoft.com

 Scroll down the home page of the TegoSoft Web site until you see the Index. One of the items in the Index is Download Runtime DLL files. Click this item from the Index to view the Download Required Runtime Modules page.

 Inside the Download Required Runtime Modules page click the VB40032.EXE hyper linked text to download the VB40032.EXE file. Save the VB40032.EXE file inside an empty temporary directory on your hard drive.

 The VB40032.EXE file that you downloaded is a self-extract file. Use the Explorer or the File Manager program to double click the VB40032.EXE file inside the directory where you save this file.

The VB40032.EXE file responds by extracting the VB40032.DLL file.

 Copy the VB40032.DLL file that you extracted from the VB40032.EXE file into your C:\Windows\System directory (or into your C:\Windows\System32 directory if you are using Windows NT).

Install WinG

The World3D.EXE program utilizes WinG technology. Thus, you must install WinG into your system. Installing WinG amounts to copy several required files into your system.

Here are the files that have to reside inside your C:\Windows\System directory (or inside your C:\Windows\System32 directory if you are using Windows NT) when you are executing programs that utilize WinG technology:

 WinG.DLL

 WinG32.DLL

 WinGDE.DLL

 WinG.DLL

 WinGDIB.DRV

 WinGPal.WND

 Use your Explorer program or the File Manager program to check if your C:\Windows\System directory (or C:\Windows\System32 directory if you are using Windows NT) has the preceding WinG files. If you are using the Explorer program, don't forget to set the View all files options as shown in Figure 1

If you are missing any of the preceding files, then download the missing files as follows:

 Log into the TegoSoft Web site at:

http://www.tegosoft.com

 Scroll down the home page of the TegoSoft Web site until you see the Index.  One of the items in the Index is Download Runtime DLL files. Click this item from the Index to view the Download Required Runtime Modules page.

 Inside the Download Required Runtime Modules page click the WinG.EXE hyper linked text to download the WinG.EXE file. Save the WinG.EXE file inside an empty temporary directory on your hard drive.

 The WinG.EXE file that you downloaded is a self-extract file. Use the Explorer or the File Manager program to double click the WinG.EXE file inside the directory where you save this file.

The WinG.EXE file responds by extracting files. The extracted files are the files that are needed when utilizing WinG technology.

 Copy the WinG files that were extracted from the WinG.EXE file into your C:\Windows\System directory (or into your C:\Windows\System32 directory if you are using Windows NT).

That's it! Your PC is now ready to execute programs that utilize WinG technology and 3-D Virtual Reality technology.


Executing the World3D program

Page 4 of 4

Executing the World3D Program

Executing the World3D Program

You'll now execute the World3D.EXE program.

That is, you already downloaded the 3DVR.EXE self-extract file from the TegoSoft Web site,  you saved the 3DVR.EXE file inside the C:\FromTego directory, and you expanded the 3DVR.EXE file. As a result, you created the C:\FromTego\3DVR directory. Inside the C:\FromTego\3DVR directory you can see the file World3D.EXE.

 NOTE

Assuming that you copied the required OCX files, the required WinG files, and the required DLL runtime modules, you can proceed with the execution of the World3D.EXE program. The previous page explains how to copy the required files to your system.

  Use the Explorer program or the Program Manager to execute the World3D.EXE program that resides inside the C:\FromTego\3DVR directory.

The window shown in Figure 2 appears. As you can see, you are currently inside a room where a man with his snake appears. Take a look at the snake, it is moving inside the basket.

Figure 2. The World3D program upon start up.

Where are you and where are you going?

Before continuing with the execution of the World3D program, you should know where are you, and where you are going. In other words, you need a map.

The World3D program uses the 2-D map (two dimensional map) shown in Figure 3 and Figure 4  The sole reason for spreading the 2-D map over two separate Figures, is because the 2-D map is too long.

The right side of Figure 3  shows that the floor is made out of 16 rooms. The lower left room is denoted as Room L1 (or L1), the room above L1 is denoted as Room L2 (or L2), and so on. The lower right room is denoted as Room R1 (or R1), the room above R1 is Room R2 (or R2), and so on. The left side of Figure 3 shows the lower rooms magnified.

Figure 3. The lower portion of the 2-D map.

Figure 4. The upper portion of the 2-D map.

Note that the rooms shown in Figure 4  are empty. But looking at Figure 3 you can see that some of these rooms have something in them.

Let's see what's inside the rooms shown in Figure 3

  Inside the room marked as Room L1 you see a solid red circle. This is where you find yourself when you start the World3D program.

  Inside the room marked as L1 you see a shaded gray area. This is your view when you start the World3D program. The black arrow indicates the direction that you are facing. And of course, just as in real life, when you face a certain direction, you can see a little bit to the right and to the left of the direction which you are facing. So basically, you are looking at the man with his snake (marked as A in Figure 3) But you can also see a small section of the hall, and you can even see a light fixture that is located on the room across the hall (inside room R1). (Because you are currently far away from room R1, the light fixture appears very small, and you see a small yellow spot which is the light that the light fixture emits).

 NOTE

In the following steps you'll be instructed to use the keyboard keys for moving inside the 3-D picture. Before pressing a key, make sure that the window of the World3D program is the selected window (so that the World3D program will react to the pressed key). You make the window of the World3D program the selected window by clicking the title of the World3D window.

 NOTE

To fully enjoy the performances of the World3D program, consider clicking the Print button that appears at the title of this page. This will print this page, and you'll have a hard copy of this page. Thus, you will not have to switch from this page to the World3D program back and forth (because you'll read the instructions from a hard copy). When printing a hard copy of this page, this page will require approximately nine 8½" by 11" pages.

 While you are inside room L1, press the left arrow key on your keyboard several times.

As a result, you are rotating counterclockwise. You are not moving forward or backward, and you are not moving to the right or to the left. You are simply changing your viewing direction.

Keep pressing the left arrow on your keyboard until you see the man with the snake again (that is, make a full 360 degrees rotation).

  While you are inside room L1, press the right arrow key on your keyboard several times.

As a result, you are rotating clockwise. You are not moving forward or backward. You are simply changing your viewing direction.

Keep pressing the right arrow on your keyboard to make a 360 degrees rotation until you see the man with the snake again.

  While you are inside room L1, press the up arrow key on your keyboard. As a result, you are advancing forward in the same direction that you are currently facing. For example, if you are currently facing the man and his snake, then pressing the up arrow key moves you closer to the man and his snake.

  While you are inside room L1, press the down arrow key on your keyboard. As a result, you are moving backward in the same direction that you are currently facing. For example, if you are currently facing the man and his snake, then pressing the down arrow key moves you away from the man and his snake.

  While you are inside room L1, practice by moving inside the L1 room. Make sure that you know how to rotate clockwise, rotate counterclockwise, move forward, and move backward. Remember, when you are moving forward or backward, you are moving in the current direction in which you are facing. Pressing the left key does not mean moving to the left, it means rotating counterclockwise. Likewise, pressing the right key does not mean moving to the right. It means rotating clockwise.

  While you are inside room L1, practice by using the mouse as follows:

While the mouse cursor is on the 3-D picture, press the left button of the mouse down, and while holding down the left button of the mouse, move the mouse forward. This has the same effect as pressing the up arrow key.

While the mouse cursor is on the 3-D picture, hold down the left button of the mouse down, and move the mouse backward. This has the same effect as pressing the down arrow key.

While the mouse cursor is on the 3-D picture, hold down the left button of the mouse down, and move the mouse to the left. This has the same effect as pressing the left arrow key.

While the mouse cursor is on the 3-D picture, hold down the left button of the mouse down, and move the mouse to the right. This has the same effect as pressing the right arrow key.

Now that you know how to move inside the L1 room, let's go to other rooms.

 Get out of the L1 room to the hall and rotate yourself so that you can see the hall. Soon enough you'll see a man running along the hall. The long red arrow that you see in Figure 3 is the path of the running man. The man starts running from one end of the hall and then runs all the way along the red arrow. When he reaches the end of the hall, he starts his journey all over again. So as you travel inside the 3-D picture, you'll occasionally see him running.

 Get inside the R1 room. As you can see,  the R1 room has a light fixture in it (see Figure 5)

Figure 5. The light fixture in the R1 room. You can turn the light On and Off by pressing the spacebar key on your keyboard.

 Press the spacebar key on your keyboard to turn the light off.

 Press the spacebar key on your keyboard again to turn the light on.

 Travel inside the R1 room for a while, and then go out to the hall. Then get inside the L2 room.

The L2 room has two trees. Figure 6 shows one of these trees.

Figure 6. The tree inside the L2 room.

 Travel inside the L2 room for a while, and then go out to the hall. Then get inside the R2 room.

The R2 room has a man in it (see Figure 7). The man is involved in heavy thinking, and he is scratching his face. (Get closer to the man to see how he is scratching his face.)

Figure 7. The man inside the R2 room. The man is involved in heavy thinking, and he is scratching his face.

 Travel inside the R2 room for a while. In particular, go around the man, and notice that when you are behind the man, you can see his back (see Figure 8).

Figure 8. The back of the man in the R2 room.

 Get out of the R2 room, and enter the R3 room.

As shown in Figure 9, the R3 room has a robot in it. The thing to note about the robot is that unlike the man in Room R2, the robot is always facing you. You can go around the robot, and you will not see its back, because the robot is always looking in your direction. Also, if you have a sound card, the robot (which happens to be a robot from out of space) will speak to you as long as you are inside the R3 room.

Figure 9. The robot in the R3 room.

 Get out of the R3 room, and enter the L3 room.

As shown in Figure 10, the L3 room has Mozart playing the piano in it. If you have a sound card in your system, the moment you enter the L3 room, you hear Mozart playing. The moment you leave the L3 room, Mozart stops playing. (Get closer to Mozart and observe his fingers.)

Figure 10. Mozart is playing music inside the L3 room. The moment you enter the L3 room, Mozart starts playing. The moment you leave the room, Mozart stops playing.

Again About the Running Man...

As you were wondering in the hall, you probably noticed the running man. The man starts at the end of the hall, and he is moving across the hall. The path of the runner is shown as the red arrow in Figure 3 When the runner reaches the end of the hall, he starts his running all over again. Your view of the runner depends where you are in relationship to the runner. If the runner is approaching you, you see his face as shown on the left side of Figure 11  If the runner is moving away from you, you see his back as shown on the right side of  Figure 11

Figure 11. If the runner is approaching you, you see his face. If the runner is moving away from you, you see his back.

About the Speed of Rotation and Movement

The speed at which you are moving or rotating with the mouse depends on the speed which you move the mouse. The faster you move the mouse, the fastest you are moving or rotating inside the 3-D picture. However, the speed in which you are moving or rotating when you use the keyboard depends on the way the PC handles the keyboard. When you'll implement the World3D program, you'll write code that handles the keyboard in two ways:

 You'll write code that handles the keyboard in the "normal" way. This produces a normal speed of rotation and movement when the user uses the keyboard.

 You'll write code that handles the keyboard in a special way. This produces faster speed of rotation and movement when the user uses the keyboard.

To see the two speeds in action, perform the following steps:

 Position yourself at the beginning of the hall, and prepare to move yourself along the hall.

 Select the Fast movement and rotation speed with keyboard item from the Keyboard menu of the World3D program.

 Now continuously press the Up arrow key on your keyboard to travel from one end of the hall to the other end of the hall.

As you can see, you are moving very fast!

 Now continuously press the Left or Right arrow key on your keyboard to continuously rotate yourself.

As you can see, you are rotating very fast!

 Select the Normal movement and rotation speed with keyboard item from the Keyboard menu of the World3D program, and repeat the preceding steps to compare the speeds. As you can see, you are now moving or rotating at a lower speed.

 Experiment with the World3D program, and then terminate the program.

 NOTE

In the preceding steps you executed the World3D program. There are several things you should know about the World3D program:

  The World3D program utilizes WinG technology.

  The World3D program is a minimum application. That is, the program only includes basic simple features. The sole purpose of the World3D program is to demonstrates basic features of the TegFlr32.OCX control.

Use your imagination as you execute the World3D program. If you have an idea for the program, write it down. (you may want to implement your idea at a later time). As an example, consider the fact that you can let your user choose two speeds. Instead of using a menu for selecting the speed, a better approach will be to let your user press the F1 key (or another key) to toggle between the speeds. As another example, instead of having to press the spacebar key to turn the light fixture in room R1 On and Off, you can draw a picture of a switch inside the R1 room, and the user will have to click the switch to turn the light On and Off.

Note that when you order the TegoSoft OCX Control Kit, you'll receive both the 32-bit OCX controls and the 16-bit OCX controls. This means for example that you'll receive the TegFlr32.OCX control as well as the TegFlr16.OCX control. Thus, you'll be able to use the TegFlr32.OCX for creating programs like the World3D program for Windows 95 and Windows NT, and you'll be able to use the TegFlr16.OCX control for creating programs like the World3D program for Windows 3.1x.


TegoSoft OCX Control Kit

Copyright © 1994, 1995, 1996 TegoSoft Inc.

All Rights Reserved

The 3-D Virtual Reality OCX Control is part of the TegoSoft OCX Control Kit.

 The complete TegoSoft OCX Control Kit includes over 20 powerful royalty-free OCX controls.

To order the OCX Control Kit,

call TegoSoft Inc. at: (516) 783-4824

The price is $29.95 plus $5.00 for shipping and handling

How to Contact TegoSoft?

Web site of TegoSoft Inc.:

http://www.tegosoft.com

e-mail of TegoSoft:

tegosoft@msn.com


*

Figure 1. Select Options from the View menu of the Explorer

program to display the Options dialog box. Inside the View page

of the Options dialog box, make sure that the Show all files radio

button is selected.


Figure 2. The World3D program upon start up.


Figure 3. The lower portion of the 2-D map.


Figure 4. The upper portion of the 2-D map.


Figure 5. The light fixture in the R1 room.

You can turn the light On and Off by pressing the

spacebar key on your keyboard.


Figure 6. The tree inside the L2 room.


Figure 7. The man inside the L2 room.

The man is involved in heavy thinking, and he is

scratching his face.


Figure 8. The back of the man in the R2 room.


Figure 9. The robot in the R3 room.


Figure 10. Mozart is playing music inside the L3 room.

The moment you enter the L3 room, Mozart starts playing.

The moment you leave the room, Mozart stops playing.


Figure 11. If the runner is approaching you, you see his face.

If the runner is moving away from you, you see his back.